/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.gamecenter.sdk.support.f;

import android.content.Context;
import android.location.Location;
import android.text.TextUtils;
import com.qihoo.gamecenter.sdk.common.f.b;
import com.qihoo.gamecenter.sdk.common.h.d;
import com.qihoo.gamecenter.sdk.common.h.d.a;
import com.qihoo.gamecenter.sdk.common.i.f;
import com.qihoo.gamecenter.sdk.common.i.k;
import com.qihoo.gamecenter.sdk.common.i.s;
import com.qihoo.gamecenter.sdk.support.g.a;
import java.util.Map;
import java.util.TreeMap;
import org.json.JSONException;
import org.json.JSONObject;

public class c extends d {
    public c(Context paramContext, d.a parama) {
        super(paramContext, parama, true);
    }

    protected String a(Context paramContext, String[] paramArrayOfString) {
        return null;
    }

    protected String a() {
        return "http://mgame.360.cn/mobile/user_config_v2";
    }

    protected boolean b() {
        return true;
    }

    protected Map b(Context paramContext, String[] paramArrayOfString) {
        return c(paramContext, paramArrayOfString);
    }

    private Map c(Context paramContext, String[] paramArrayOfString) {
        String str1 = a(0, paramArrayOfString);
        if (TextUtils.isEmpty(str1))
            return null;
        TreeMap localTreeMap = new TreeMap();
        localTreeMap.put("user_id", str1);
        localTreeMap.put("app_key", s.r(paramContext));
        localTreeMap.put("t", String.valueOf(System.currentTimeMillis()));
        String str2 = b(paramContext);
        a.a("MGUserConfigTask", new Object[] { "quickInfo=", str2 });
        if (!(TextUtils.isEmpty(str2)))
            localTreeMap.put("quick_info", str2);
        String str3 = a(paramContext);
        a.a("MGUserConfigTask", new Object[] { "riskControl=", str3 });
        if (!(TextUtils.isEmpty(str3)))
            localTreeMap.put("risk_control", str3);
        String str4 = s.a(localTreeMap, s.s(paramContext));
        if (b()) {
            this.a = s.b();
            String str5 = f.c(str4, this.a);
            String str6 = b.a().a(this.a);
            localTreeMap = new TreeMap();
            localTreeMap.put("k", str6);
            localTreeMap.put("d", str5);
            a.a("MGUserConfigTask", new Object[] { a(), "?k=", str6, "&d=", str5 });
        }
        return localTreeMap;
    }

    protected a b(JSONObject paramJSONObject) {
        if (paramJSONObject != null) {
            boolean bool1 = true;
            int i = 600000;
            int j = 900000;
            boolean bool2 = true;
            boolean bool3 = true;
            boolean bool4 = true;
            String str = "";
            int k = paramJSONObject.optInt("error_code", -1);
            if (k == 0) {
                localObject = paramJSONObject.optJSONObject("module_config");
                if (localObject != null) {
                    JSONObject localJSONObject1 = ((JSONObject) localObject).optJSONObject("switch");
                    if (localJSONObject1 != null) {
                        JSONObject localJSONObject2 = localJSONObject1.optJSONObject("message");
                        if (localJSONObject2 != null) {
                            bool1 = localJSONObject2.optInt("is_on") == 1;
                            i = localJSONObject2.optInt("min_interval") * 1000;
                            j = localJSONObject2.optInt("max_interval") * 1000;
                        }
                        JSONObject localJSONObject3 = localJSONObject1.optJSONObject("memory_clear");
                        if (localJSONObject3 != null)
                            bool2 = localJSONObject3.optInt("is_on") == 1;
                        JSONObject localJSONObject4 = localJSONObject1.optJSONObject("customer_service");
                        if (localJSONObject4 != null)
                            bool3 = localJSONObject4.optInt("is_on") == 1;
                        JSONObject localJSONObject5 = localJSONObject1.optJSONObject("forum");
                        if (localJSONObject5 != null) {
                            bool4 = localJSONObject5.optInt("is_on") == 1;
                            str = localJSONObject5.optString("url");
                            if ((bool4) && (TextUtils.isEmpty(str)))
                                bool4 = false;
                        }
                    }
                }
            }
            a.a("MGUserConfigTask", new Object[] { "showMessage=", Boolean.valueOf(bool1) });
            a.a("MGUserConfigTask", new Object[] { "showMemoryClear=", Boolean.valueOf(bool2) });
            a.a("MGUserConfigTask", new Object[] { "showPayService=", Boolean.valueOf(bool3) });
            a.a("MGUserConfigTask", new Object[] { "showBBS=", Boolean.valueOf(bool4) });
            a.a("MGUserConfigTask", new Object[] { "bbsUrl=", str });
            a.a("MGUserConfigTask", new Object[] { "messageMinInterval=", Integer.valueOf(i) });
            a.a("MGUserConfigTask", new Object[] { "messageMaxInterval=", Integer.valueOf(j) });
            Object localObject = new a();
            ((a) localObject).a(k);
            ((a) localObject).a(paramJSONObject.toString());
            ((a) localObject).a(bool1);
            ((a) localObject).b(i);
            ((a) localObject).c(j);
            ((a) localObject).b(bool2);
            ((a) localObject).c(bool3);
            ((a) localObject).d(bool4);
            ((a) localObject).b(str);
            return localObject;
        }
        return ((a) null);
    }

    private static String b(Context paramContext) {
        JSONObject localJSONObject = new JSONObject();
        String str1 = k.a(s.j(paramContext));
        a.a("MGUserConfigTask", new Object[] { "did=", str1 });
        try {
            if (!(TextUtils.isEmpty(str1)))
                localJSONObject.put("did", str1);
        } catch (JSONException localJSONException) {
            a.b("MGUserConfigTask", new Object[] { localJSONException.toString() });
        }
        String str2 = localJSONObject.toString();
        a.a("MGUserConfigTask", new Object[] { "quickInfo=", str2 });
        return b.a().a(str2);
    }

    public static String a(Context paramContext) {
        JSONObject localJSONObject = new JSONObject();
        String str1 = null;
        String str2 = null;
        String str3 = null;
        String str4 = s.k(paramContext);
        String str5 = s.l(paramContext);
        String str6 = s.m(paramContext);
        Location localLocation = new Location("");
        if ((localLocation != null) && (!(TextUtils.isEmpty(localLocation.getProvider())))) {
            a.a("MGUserConfigTask", new Object[] { "loc=", localLocation.toString() });
            str1 = String.valueOf(localLocation.getLatitude());
            str2 = String.valueOf(localLocation.getLongitude());
            str3 = String.valueOf(localLocation.getTime());
        }
        try {
            if ((!(TextUtils.isEmpty(str1))) && (!(TextUtils.isEmpty(str2)))) {
                String str7 = str1 + "|" + str2 + "|" + str3;
                if (str7.length() > 64)
                    str7 = str7.substring(0, 64);
                localJSONObject.put("position", str7);
            }
            if (!(TextUtils.isEmpty(str4)))
                localJSONObject.put("imsi", str4);
            if (!(TextUtils.isEmpty(str5)))
                localJSONObject.put("mac", str5);
            if (!(TextUtils.isEmpty(str6)))
                localJSONObject.put("mobile_num", str6);
        } catch (JSONException localJSONException) {
            a.c("MGUserConfigTask", new Object[] { localJSONException.toString() });
        }
        return b.a().a(localJSONObject.toString());
    }

    public static class a {
        private int a = -1;
        private String b = "";
        private boolean c = true;
        private int d = 600000;
        private int e = 900000;
        private boolean f = true;
        private boolean g = true;
        private boolean h = true;
        private String i = "";

        public void a(int paramInt) {
            this.a = paramInt;
        }

        public String a() {
            return this.b;
        }

        public void a(String paramString) {
            this.b = paramString;
        }

        public boolean b() {
            return this.c;
        }

        public void a(boolean paramBoolean) {
            this.c = paramBoolean;
        }

        public int c() {
            return this.d;
        }

        public void b(int paramInt) {
            this.d = paramInt;
        }

        public int d() {
            return this.e;
        }

        public void c(int paramInt) {
            this.e = paramInt;
        }

        public boolean e() {
            return this.f;
        }

        public void b(boolean paramBoolean) {
            this.f = paramBoolean;
        }

        public boolean f() {
            return this.g;
        }

        public void c(boolean paramBoolean) {
            this.g = paramBoolean;
        }

        public boolean g() {
            return this.h;
        }

        public void d(boolean paramBoolean) {
            this.h = paramBoolean;
        }

        public void b(String paramString) {
            this.i = paramString;
        }

        public String h() {
            return this.i;
        }
    }
}